<?php

namespace app\shop\controller;

use think\Request;
use think\Exception;
use think\Db;
use app\shop\model\StaffTag as StaffTagModel;

class StaffTag extends \ShopController{

    //标签列表
    public function tagList(Request $request){
        $tagModel = new StaffTagModel();
        try {
            $params = $request->get();
            $data = $tagModel->tagList($params);
            $this->successTerminate($data);
        } catch (Exception $e) {
            $this->serverErrorTerminate($e->getMessage());
        }
    }

    //添加标签
    public function add(Request $request){
        $tagModel = new StaffTagModel();
        try {
            $params = $request->post();
            $data = $tagModel->add($params);
            $this->successTerminate($data);
        } catch (Exception $e) {
            $this->serverErrorTerminate($e->getMessage());
        }
    }

    //标签重命名
    public function rename(Request $request){
        $tagModel = new StaffTagModel();
        try {
            $params = $request->post();
            $data = $tagModel->rename($params);
            $this->successTerminate($data);
        } catch (Exception $e) {
            $this->serverErrorTerminate($e->getMessage());
        }
    }

    //删除标签
    public function del_tag($id){
        $tagModel = new StaffTagModel();
        try {
            $data = $tagModel->del_tag($id);
            $this->successTerminate($data);
        } catch (Exception $e) {
            $this->serverErrorTerminate($e->getMessage());
        }
    }

}